.class public Lde/dealdoktor/app/activities/PostListing$GetPostsTask;
.super Landroid/os/AsyncTask;
.source "PostListing.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lde/dealdoktor/app/activities/PostListing;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0xc
    name = "GetPostsTask"
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask",
        "<",
        "Ljava/lang/String;",
        "Ljava/lang/Void;",
        "Ljava/lang/Boolean;",
        ">;"
    }
.end annotation


# static fields
.field private static act:Ljava/lang/ref/WeakReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/WeakReference",
            "<",
            "Lde/dealdoktor/app/activities/PostListing;",
            ">;"
        }
    .end annotation
.end field


# instance fields
.field private isAddNewPosts:Z

.field loadingText:Landroid/widget/TextView;

.field private posts:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lde/dealdoktor/app/data/PostDAO;",
            ">;"
        }
    .end annotation
.end field

.field requestId:I


# direct methods
.method public constructor <init>(Ljava/lang/ref/WeakReference;)V
    .locals 1
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/ref/WeakReference",
            "<",
            "Lde/dealdoktor/app/activities/PostListing;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 100
    .local p1, act:Ljava/lang/ref/WeakReference;,"Ljava/lang/ref/WeakReference<Lde/dealdoktor/app/activities/PostListing;>;"
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;-><init>(Ljava/lang/ref/WeakReference;Z)V

    .line 101
    return-void
.end method

.method public constructor <init>(Ljava/lang/ref/WeakReference;Z)V
    .locals 0
    .parameter
    .parameter "isAddNewPosts"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/ref/WeakReference",
            "<",
            "Lde/dealdoktor/app/activities/PostListing;",
            ">;Z)V"
        }
    .end annotation

    .prologue
    .line 103
    .local p1, act:Ljava/lang/ref/WeakReference;,"Ljava/lang/ref/WeakReference<Lde/dealdoktor/app/activities/PostListing;>;"
    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    .line 104
    iput-boolean p2, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->isAddNewPosts:Z

    .line 105
    sput-object p1, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    .line 106
    return-void
.end method

.method static synthetic access$2()Ljava/lang/ref/WeakReference;
    .locals 1

    .prologue
    .line 95
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    return-object v0
.end method


# virtual methods
.method protected varargs doInBackground([Ljava/lang/String;)Ljava/lang/Boolean;
    .locals 4
    .parameter "args"

    .prologue
    .line 147
    :try_start_0
    iget-boolean v1, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->isAddNewPosts:Z

    if-eqz v1, :cond_0

    .line 148
    sget-object v1, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->size()I

    move-result v1

    if-nez v1, :cond_1

    .line 149
    sget-object v1, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lde/dealdoktor/app/activities/PostListing;

    new-instance v2, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$1;

    invoke-direct {v2, p0}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$1;-><init>(Lde/dealdoktor/app/activities/PostListing$GetPostsTask;)V

    invoke-virtual {v1, v2}, Lde/dealdoktor/app/activities/PostListing;->runOnUiThread(Ljava/lang/Runnable;)V

    .line 156
    new-instance v2, Lde/dealdoktor/app/data/DataModel;

    invoke-direct {v2}, Lde/dealdoktor/app/data/DataModel;-><init>()V

    sget-object v1, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/content/Context;

    invoke-virtual {v2, v1}, Lde/dealdoktor/app/data/DataModel;->getCategories(Landroid/content/Context;)Ljava/util/ArrayList;

    move-result-object v1

    sput-object v1, Lde/dealdoktor/app/App;->categories:Ljava/util/ArrayList;

    .line 172
    :cond_0
    :goto_0
    sget-object v1, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lde/dealdoktor/app/activities/PostListing;

    new-instance v2, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$3;

    invoke-direct {v2, p0}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$3;-><init>(Lde/dealdoktor/app/activities/PostListing$GetPostsTask;)V

    invoke-virtual {v1, v2}, Lde/dealdoktor/app/activities/PostListing;->runOnUiThread(Ljava/lang/Runnable;)V

    .line 177
    const-string v1, "xxx"

    const-string v2, "loading"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 179
    sget-object v1, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/content/Context;

    sget v2, Lde/dealdoktor/app/App;->postsCurrentPage:I

    invoke-static {v1, v2}, Lde/dealdoktor/app/data/DataModel;->getCategoryPosts(Landroid/content/Context;I)Ljava/util/ArrayList;

    move-result-object v1

    iput-object v1, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    .line 180
    const-string v1, "xxx"

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "loaded"

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v3, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 185
    const/4 v1, 0x1

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    :goto_1
    return-object v1

    .line 160
    :cond_1
    :try_start_1
    new-instance v1, Ljava/lang/Thread;

    new-instance v2, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$2;

    invoke-direct {v2, p0}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask$2;-><init>(Lde/dealdoktor/app/activities/PostListing$GetPostsTask;)V

    invoke-direct {v1, v2}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 168
    invoke-virtual {v1}, Ljava/lang/Thread;->start()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 181
    :catch_0
    move-exception v0

    .line 182
    .local v0, e:Ljava/lang/Exception;
    const-string v1, "exception"

    const-string v2, "GetPostsTask doInBackground"

    invoke-static {v1, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    .line 183
    const/4 v1, 0x0

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    goto :goto_1
.end method

.method protected bridge varargs synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .locals 1
    .parameter

    .prologue
    .line 1
    check-cast p1, [Ljava/lang/String;

    invoke-virtual {p0, p1}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->doInBackground([Ljava/lang/String;)Ljava/lang/Boolean;

    move-result-object v0

    return-object v0
.end method

.method protected onPostExecute(Ljava/lang/Boolean;)V
    .locals 3
    .parameter "success"

    .prologue
    const/4 v2, 0x0

    .line 123
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    if-eqz v0, :cond_1

    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    invoke-virtual {v0}, Lde/dealdoktor/app/activities/PostListing;->isFinishing()Z

    move-result v0

    if-nez v0, :cond_1

    iget v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->requestId:I

    sget v1, Lde/dealdoktor/app/App;->requestId:I

    if-ne v0, v1, :cond_1

    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    if-eqz v0, :cond_1

    .line 124
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    invoke-virtual {v0}, Ljava/util/ArrayList;->size()I

    move-result v0

    if-lez v0, :cond_0

    .line 125
    sget v0, Lde/dealdoktor/app/App;->postsCurrentPage:I

    add-int/lit8 v0, v0, 0x1

    sput v0, Lde/dealdoktor/app/App;->postsCurrentPage:I

    .line 128
    :cond_0
    invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-nez v0, :cond_2

    .line 129
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iput-boolean v2, v0, Lde/dealdoktor/app/activities/PostListing;->isLoading:Z

    .line 142
    :cond_1
    :goto_0
    return-void

    .line 132
    :cond_2
    iget-object v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    invoke-virtual {v0}, Ljava/util/ArrayList;->size()I

    move-result v0

    if-lez v0, :cond_3

    .line 133
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->listAdapter:Lde/dealdoktor/app/adapter/PostListAdapter;

    iget-object v1, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->posts:Ljava/util/ArrayList;

    invoke-virtual {v0, v1}, Lde/dealdoktor/app/adapter/PostListAdapter;->addData(Ljava/util/ArrayList;)V

    .line 134
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iput-boolean v2, v0, Lde/dealdoktor/app/activities/PostListing;->isLoading:Z

    .line 136
    :cond_3
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-boolean v0, v0, Lde/dealdoktor/app/activities/PostListing;->isLoading:Z

    if-eqz v0, :cond_1

    .line 137
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->loadingView:Landroid/view/View;

    const v1, 0x7f0b003b

    invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    const/16 v1, 0x8

    invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V

    .line 138
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->loadingView:Landroid/view/View;

    const v1, 0x7f0b003d

    invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    invoke-virtual {v0, v2}, Landroid/view/View;->setVisibility(I)V

    goto :goto_0
.end method

.method protected bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0
    .parameter

    .prologue
    .line 1
    check-cast p1, Ljava/lang/Boolean;

    invoke-virtual {p0, p1}, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->onPostExecute(Ljava/lang/Boolean;)V

    return-void
.end method

.method protected onPreExecute()V
    .locals 2

    .prologue
    .line 111
    sget v0, Lde/dealdoktor/app/App;->requestId:I

    add-int/lit8 v0, v0, 0x1

    sput v0, Lde/dealdoktor/app/App;->requestId:I

    iput v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->requestId:I

    .line 112
    iget-boolean v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->isAddNewPosts:Z

    if-eqz v0, :cond_0

    .line 113
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->listAdapter:Lde/dealdoktor/app/adapter/PostListAdapter;

    invoke-virtual {v0}, Lde/dealdoktor/app/adapter/PostListAdapter;->clear()V

    .line 115
    :cond_0
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    const/4 v1, 0x1

    iput-boolean v1, v0, Lde/dealdoktor/app/activities/PostListing;->isLoading:Z

    .line 116
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->loadingView:Landroid/view/View;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V

    .line 118
    sget-object v0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->act:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lde/dealdoktor/app/activities/PostListing;

    iget-object v0, v0, Lde/dealdoktor/app/activities/PostListing;->loadingView:Landroid/view/View;

    const v1, 0x7f0b003c

    invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/TextView;

    iput-object v0, p0, Lde/dealdoktor/app/activities/PostListing$GetPostsTask;->loadingText:Landroid/widget/TextView;

    .line 119
    return-void
.end method
